<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MY_Model
 *
 * @author flg
 */
class base_model extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    final public function update() {
        $this->__check_connect();
        return call_user_func_array(array($this->db, "update"), func_get_args());
    }


    final public function get() {
        $this->__check_connect();
        return call_user_func_array(array($this->db, "get"), func_get_args());
    }

    final public function replace() {
        $this->__check_connect();
        return call_user_func_array(array($this->db, "replace"), func_get_args());
    }
    
    final public function insert($table, $data) {
        $this->__check_connect();
        return call_user_func_array(array($this->db, "insert"), func_get_args());
    }

    final public function delete() {
        $this->__check_connect();
        return call_user_func_array(array($this->db, "delete"), func_get_args());
    }

    final public function where() {
        call_user_func_array(array($this->db, "where"), func_get_args());
    }

    final public function where_in() {
        call_user_func_array(array($this->db, "where_in"), func_get_args());
    }

    final public function like() {
        call_user_func_array(array($this->db, "like"), func_get_args());
    }

    function __check_connect() {
        //监测数据库连接状态
        if (@mysqli_ping($this->db->conn_id) === False) {
            echo "heart gone away\n";
            $this->db->reconnect();
            $this->db->initialize();
        }
    }

}
